<?php

class Mascota extends AppModel {
	var $name='Mascota';

	var $hasOne = array(
				'Perdido' => array(
						'className' => 'Perdido',
						'conditions' => '',
						'limit' => '',
						'foreignKey' => 'mascota_id',
						'dependent' => true,
						'finderQuery' => ''
				),
				'Encontrado' => array(
						'className' => 'Encontrado',
						'conditions' => '',
						'limit' => '',
						'foreignKey' => 'mascota_id',
						'dependent' => true,
						'finderQuery' => ''
				),
				'Recuperado' => array(
						'className' => 'Recuperado',
						'conditions' => '',
						'limit' => '',
						'foreignKey' => 'mascota_id',
						'dependent' => true,
						'finderQuery' => ''
				)
		);

	var $hasMany = array(
				'Image' => array(
						'className' => 'Image',
						'conditions' => '',
						'limit' => '',
						'foreignKey' => 'mascota_id',
						'dependent' => true,
						'finderQuery' => ''
				)
		);

	function add($data)
	{
		if (isset($data['Mascota']['id']) || !empty($data['Mascota']['id'])){
			$this->id = $data['Mascota']['id'];
			unset($data['Mascota']['id']);
		}else{
			$data['Mascota']['created'] = date('Y-m-d H:i:s');
		}
		return $this->save($data);
	}

}
?>
